

const getToken= require('../../utils/get_token.js');
const formatTime = require('../../utils/util.js');
let md = '', id = '';
let cookie, token;
const ckToken = async (that) => {//token确认
  let nTime = Math.floor(new Date().getTime() / 1000);
  let oldTime = wx.getStorageSync('ntime') || 0;
  if (nTime < oldTime)//现在的时间小于到期时间
  {
    indexList(that);
  } else {
    let tokens = await getToken.getToken();
    indexList(that);
  }
}
const indexList = (that) => {
  let params = ['shop/order/mailInfoNew', {"orderSn":id}]
  getToken.getData(function (res) {
    console.log(res.data)
    let ds = res.data;
    if (ds.flag) {
      if (ds.mail.number == "undefined")
        ds.mail.number = '';
      that.setData({
        s: ds.mail,
        gimg: that.data.gimg
      })
    }
  }, ...params)
};

Page({

  /**
   * 页面的初始数据
   */
  data: {
    list: [],
    boolT: true,
    gimg:'',
    tuanShow: false,
    s: {}

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let that = this;
    cookie = wx.getStorageSync('cookie') || '';
    token = wx.getStorageSync('token') || '';
    id = options.id || '';
    that.data.gimg = wx.getStorageSync('wimg') || '';
    ckToken(that);
  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})